const { model } = require('mongoose')
const mongoose = require('./db')

// model字段定义
const cateList = new mongoose.Schema({
    title: String,
    image: String,
    desc: String,
    cid: Number
})
const MvList = new mongoose.Schema({
    title: String,
    cid: Number,
    desc: String,
    images: Array,
    classList: Array
})

const cateListModel = mongoose.model('Catelist', cateList, 'Catelist')
const MvListModel = mongoose.model('Mvlist', MvList, 'Mvlist')

const commentSchema = new mongoose.Schema({
    name: String,         // 评论者姓名
    content: String,      // 评论内容
    parent: {           // 父评论引用
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Comment',
        default: null
    },
    created_at: {
        type: Date,
        default: Date.now
    }
});


const Comment = mongoose.model('Comment', commentSchema, 'Comment');

module.exports = {
    cateListModel,
    MvListModel,
    Comment
}